package com.thread.www;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;

/**
 * Created by 27340 on 2017/3/26.
 */
public class ForkJoinTaskTest {
    public static void main(String[] args){
        ForkJoinPool forkJoinPool = new ForkJoinPool();
        CountTask countTask = new CountTask(1 , 5);
        Future<Integer> result = forkJoinPool.submit(countTask);
        try {
            System.out.println("1-5最终结果：" + result.get());
            CountTask countTask1 = new CountTask(1 , 100);
            Future<Integer> result1 = forkJoinPool.submit(countTask1);
            System.out.println("1-100最终结果：" + result1.get());
            System.out.println("Thread Main end!");
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
